﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;

namespace Sumc.Client.ModernUI.Controls
{
    public class AlternatingListView : ListView
    {
        protected override void
            PrepareContainerForItemOverride(DependencyObject element,
            object item)
        {
            base.PrepareContainerForItemOverride(element, item);
            int index = ItemContainerGenerator.IndexFromContainer(element);
            var lvi = element as ListViewItem;

            if (index % 2 == 0)
            {
                var color = new Color();
                color.R = 58;
                color.G = 102;
                color.B = 228;
                color.A = 255;
                lvi.Background = new SolidColorBrush(color);
            }
            else
            {
                var color = new Color();
                color.R = 61;
                color.G = 61;
                color.B = 61;
                color.A = 255;
                lvi.Background = new SolidColorBrush(color);
            }
        }
    }
}
